<template>
    <div style="height: 95%;width: 100%;display:flex;justify-content:center;padding-top: 20px">
        <!--弹框DIV 设置弹框的大小的地方-->
        <div style="background: #fff;width: 700px;height: 600px;box-shadow: #D3DCE6 0px 0px 20px;">
            <div style="height:520px;border: #1C84C6;margin-top: 25px" class="scrollbar">
                <div style="height: 30px;">
                    <!--标题-->
                    <span style="font-size: 18px;margin-left: 25px;">
                        新建退货单
                    </span>
                    <!--返回列表-->
                        <span style="margin-left: 530px;" @click="tzdz">
                            <i slot="suffix" style="font-size: 30px;color: #D3DCE6" class="el-icon-close"></i>
                        </span>
                </div>
                <!--height:91%;表单在弹框显示多长-->
                <el-scrollbar style="height:91%;padding-top: 20px;">
                    <div class="shugan"></div>
                    <span style="margin-left: 10px;font-size: 14px;">基本信息</span>
                    <br/>
                    <br/>
                    <!--表单-->
                    <el-form style="margin-top:5px;margin-left: 30px;" :rules="rules" size="mini" :model="thdlist"  ref="thdlist">
                        <el-row>
                            <el-col :span="10">
                                <el-form-item style="width:250px;">
                                    <label slot="label" style="font-size: 13px">主题：</label><br/>
                                    <el-input v-model="thdlist.returgoodTheme"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="width:250px">
                                    <label slot="label" style="font-size: 13px">退货编号：</label><br/>
                                    <el-input :disabled="true" v-model="thdlist.returgoodNo"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item style="width:250px;" prop="clientId">
                                    <label slot="label" style="font-size: 13px">客户：</label><br/>
                                    <!--客户名称-->
                                    <el-popover
                                            style="width: 700px; height: 450px;"
                                            placement="right"
                                            trigger="click"
                                            v-model="kehu">
                                        <span style="font-size: 16px;">关联客户模块</span>
                                        <br/>
                                        <el-input @keyup.enter.native="cx" v-model="kehuinput" style="width: 210px; margin-left: 230px; margin-bottom: 10px;">
                                            <i slot="suffix" class="el-input__icon el-icon-search" @click="cx"></i>
                                        </el-input>
                                        <el-button type="primary" style="margin-left: 130px;">新 建</el-button>
                                        <el-table
                                                highlight-current-row
                                                border
                                                ref="kehulist"
                                                :data="kehulist">
                                            <el-table-column type="selection" width="50" align="center" property="clientId"></el-table-column>
                                            <el-table-column width="150" property="clientName" label="客户名称"></el-table-column>
                                            <el-table-column width="100" property="clientRank" label="级别"></el-table-column>
                                            <el-table-column width="150" property="clientMobile" label="手机号码"></el-table-column>
                                            <el-table-column property="clientSite" label="地址"></el-table-column>
                                        </el-table>
                                        <el-pagination
                                                style="margin-left: 350px;"
                                                layout="prev, pager, next"
                                                :page-size="pageSize"
                                                :current-page.sync="currPage"
                                                @current-change="handleCurrentChange"
                                                :total="totalSize">
                                        </el-pagination>
                                        <div style="text-align: center;width: 100%" class="dialog-footer">
                                            <el-button type="primary" @click="xzkehu">保 存</el-button>
                                            <el-button type="primary" @click="kehu = false">取 消</el-button>
                                        </div>
                                        <el-input v-if="this.xg==0" v-model="thdlist.clientId.clientName" placeholder="+添加" slot="reference" :readonly='true' style="width: 250px;"></el-input>
                                    </el-popover>
                                    <el-input v-if="this.xg==1" :disabled="true" v-model="thdlist.clientId.clientName" placeholder="+添加" :readonly='true' style="width: 250px;"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="width:250px" prop="orderId">
                                    <label slot="label" style="font-size: 13px">订单：</label><br/>
                                    <!--订单-->
                                    <el-popover
                                            style="width: 700px; height: 450px;"
                                            placement="right"
                                            trigger="click"
                                            v-model="dindan">
                                        <span style="font-size: 16px;">关联订单模块</span>
                                        <br/>
                                        <el-input @keyup.enter.native="cx2" v-model="dindaninput" style="width: 210px; margin-left: 230px; margin-bottom: 10px;">
                                            <i slot="suffix" class="el-input__icon el-icon-search" @click="cx2"></i>
                                        </el-input>
                                        <el-button type="primary" style="margin-left: 100px;">新 建</el-button>
                                        <el-table
                                                highlight-current-row
                                                border
                                                ref="dindanlist"
                                                :data="dindanlist">
                                            <el-table-column type="selection" width="50" align="center" property="returnedmoneyId"></el-table-column>
                                            <el-table-column width="150" property="orderTheme" label="主题"></el-table-column>
                                            <el-table-column label="下单时间" align="center" width="200">
                                                <template slot-scope="d">
                                                    {{d.row.orderTime | formatDate}}
                                                </template>
                                            </el-table-column>
                                            <el-table-column width="100" property="orderReturned" label="已回款金额"></el-table-column>
                                            <el-table-column width="100" property="orderTotal" label="总金额"></el-table-column>
                                        </el-table>
                                        <el-pagination
                                                style="margin-left: 350px;"
                                                layout="prev, pager, next"
                                                :page-size="pageSize2"
                                                @current-change="handleCurrentChange2"
                                                :current-page.sync="currPage2"
                                                :total="totalSize2">
                                        </el-pagination>
                                        <div style="text-align: center;width: 100%" class="dialog-footer">
                                            <el-button type="primary" @click="xzdd">保 存</el-button>
                                            <el-button type="primary" @click="dindan = false">取 消</el-button>
                                        </div>
                                        <el-input  v-if="this.xg==0" v-model="thdlist.orderId.orderTheme" @focus="dakai" placeholder="+添加" slot="reference" :readonly='true' style="width: 250px;"></el-input>
                                    </el-popover>
                                    <el-input v-if="this.xg==1" :disabled="true" v-model="thdlist.orderId.orderTheme" placeholder="+添加" :readonly='true' style="width: 250px;"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item prop="chukuId">
                                    <label slot="label" style="font-size: 13px" >出库单：</label><br/>
                                    <el-popover
                                            style="width: 700px; height: 450px;"
                                            placement="right"
                                            trigger="click"
                                            v-model="chuku">
                                        <span style="font-size: 16px;">关联出库模块</span>
                                        <br/>
                                        <el-input @keyup.enter.native="cx4" v-model="chukuinput" style="width: 210px; margin-left: 230px; margin-bottom: 10px;">
                                            <i slot="suffix" class="el-input__icon el-icon-search" @click="cx4"></i>
                                        </el-input>
                                        <el-button type="primary" style="margin-left: 100px;">新 建</el-button>
                                        <el-table
                                                highlight-current-row
                                                border
                                                ref="chukulist"
                                                :data="chukulist">
                                            <el-table-column type="selection" width="50" align="center" property="chukuId"></el-table-column>
                                            <el-table-column  property="chukuNo" label="出库单号"></el-table-column>
                                            <el-table-column label="出库时间" align="center" width="200">
                                                <template slot-scope="d">
                                                    {{d.row.chukuTime | formatDate}}
                                                </template>
                                            </el-table-column>
                                            <el-table-column  property="chukuCanku" label="仓库"></el-table-column>
                                        </el-table>
                                        <el-pagination
                                                style="margin-left: 350px;"
                                                layout="prev, pager, next"
                                                :page-size="pageSize4"
                                                :current-page.sync="currPage4"
                                                @current-change="handleCurrentChange4"
                                                :total="totalSize4">
                                        </el-pagination>
                                        <div style="text-align: center;width: 100%" class="dialog-footer">
                                            <el-button type="primary" @click="xzck">保 存</el-button>
                                            <el-button type="primary" @click="dindan = false">取 消</el-button>
                                        </div>
                                        <el-input  v-if="this.xg==0" v-model="thdlist.chukuId.chukuNo" @focus="dakai2" placeholder="+添加" slot="reference" :readonly='true' style="width: 250px;"></el-input>
                                    </el-popover>
                                    <el-input v-if="this.xg==1" :disabled="true" v-model="thdlist.chukuId.chukuNo" placeholder="+添加" :readonly='true' style="width: 250px;"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="width:250px" prop="returgoodTime">
                                    <label slot="label" style="font-size: 13px" >退货日期：</label><br/>
                                    <el-date-picker
                                            v-model="thdlist.returgoodTime"
                                            align="right"
                                            type="date"
                                            style="width: 250px "
                                            placeholder="选择日期"
                                            :picker-options="pickerOptions">
                                    </el-date-picker>

                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item style="width:250px;">
                                    <label slot="label" style="font-size: 13px">应退款：</label><br/>
                                    <el-input :disabled="true" v-model="thdlist.returgoodYreimburse"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="width:250px">
                                    <label slot="label" style="font-size: 13px">剩余退款：</label><br/>
                                    <el-input :disabled="true" v-model="thdlist.returgoodReimburse"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item style="width:270px">
                                    <label slot="label" style="font-size: 13px">经办人：</label><br/>
                                    <el-input :disabled="true" v-model="thdlist.returgoodPeople"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                    <br/>
                    <span style="margin-left:30px;font-size: 13px">产品</span>
                    <br/>

                    <!--添加产品按钮-->
                    <el-popover
                            style="width: 700px; height: 450px;"
                            placement="left"
                            trigger="click"
                            v-model="chanp"
                            >
                        <span style="font-size: 16px;">关联产品模块</span>
                        <br/>
                        <el-input @keyup.enter.native="cx3" v-model="chanpinput" size="mini" style="width: 210px; margin-left: 230px; margin-bottom: 10px;">
                            <i slot="suffix" class="el-input__icon el-icon-search" @click="cx3"></i>
                        </el-input>
                        <el-button type="primary" size="mini" style="margin-left: 130px;">新 建</el-button>

                        <el-table
                                :data="proList"
                                ref="multipleSelection"
                                highlight-current-row
                                border>
                            <el-table-column
                                    prop="chukuxqId"
                                    type="selection"
                                    width="50"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    prop="prodetailId.productName"
                                    label="产品名称"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    label="产品规格"
                                    align="center">
                                <template slot-scope="s">
                                        <span v-for="pro in s.row.prodetailId.qmodeldetails" :key="pro.prodetailId">
                                            {{pro.modetContent}}
                                        </span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                    prop="chukuJg"
                                    label="售价"
                                    align="center">
                            </el-table-column>
                            <el-table-column
                                    prop="chukuKetueinumber"
                                    label="剩余退货数量"
                                    align="center">
                            </el-table-column>
                        </el-table>
                        <el-pagination
                                style="margin-left: 350px;"
                                layout="prev, pager, next"
                                @current-change="handleCurrentChange3"
                                :current-page="currPage3"
                                :page-size="pageSize3"
                                :total="totalSize3">
                        </el-pagination>
                        <div style="text-align: center;width: 100%" class="dialog-footer">
                            <el-button type="primary" @click="trueaddpro">保 存</el-button>
                            <el-button type="primary" @click="chanp = false">取 消</el-button>
                        </div>
                        <el-button slot="reference" size="mini" :readonly='true' style="margin-left:510px;" type="primary" @click="initProData">添加商品</el-button>
                    </el-popover>
                    <el-table :data="thdlist.thxq" style="width: 80%;margin-left: 10px;font-size:13px">
                        <el-table-column
                                align="center"
                                prop="prodetailId.productName"
                                label="产品名称"
                                width="90">
                        </el-table-column>
                        <el-table-column
                                align="center"
                                label="产品规格"
                                width="150">
                            <template slot-scope="s">
                                <span v-for="pro in s.row.prodetailId.qmodeldetails" :key="pro.prodetailId">
                                    {{pro.modetContent}}
                                </span>
                            </template>
                        </el-table-column>
                        <el-table-column
                                align="center"
                                label="售价"
                                prop="regodetailJg"
                                width="90">
                        </el-table-column>
                        <el-table-column
                                align="center"
                                label="数量"
                                width="150">
                            <template slot-scope="d">
                                <el-input-number @change="discount()" size="mini" :min="1" :max="d.row.sl"  v-model="d.row.regodetailNum"></el-input-number>
                            </template>
                        </el-table-column>
                        <el-table-column
                                align="center"
                                label="备注">
                            <template slot-scope="d">
                                <el-input size="mini" v-model="d.row.regodetailBz" ></el-input>
                            </template>
                        </el-table-column>
                    </el-table>
                    <br/>
                    <div style="margin-left:540px;font-size: 12px;margin-top: 10px;">
                        <span>总金额：{{this.thdlist.returgoodYreimburse}}</span>
                        <span>元</span>
                    </div>
                    <br/>
                </el-scrollbar>
                <!--确定按钮 设置了固定定位-->
                <div style="text-align: center;width: 80%;position: absolute;top:640px;left:230px;" class="dialog-footer">
                    <!--跳合同订单列表页面-->
                        <el-button @click="tzdz">取 消</el-button>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <el-button type="primary" @click="addbusiness('thdlist')">确 定</el-button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import {formatTimeToStr} from '../router//format.js'
    export default {
        name: "Zxinzentueihuo",
        data () {
            var hueikuan = (rule, value, callback) => {
                if (this.thdlist.clientId.clientName === null || this.thdlist.clientId.clientName === '') {
                    callback(new Error('请先选择客户'));
                } else {
                    if (this.thdlist.orderId.orderTheme === '' || this.thdlist.orderId.orderTheme === null) {
                        callback(new Error('请选择计划'));
                    }else {
                        callback()
                    }
                }
            };
            var chuku = (rule, value, callback) => {
                if (this.thdlist.orderId.orderTheme === null || this.thdlist.orderId.orderTheme === '') {
                    callback(new Error('请先选择对应订单'));
                } else {
                    if (this.thdlist.chukuId.chukuNo === '' || this.thdlist.chukuId.chukuNo === null) {
                        callback(new Error('请选择出库单'));
                    }else {
                        callback()
                    }
                }
            };
            var kehua = (rule, value, callback) => {
                if (value.clientName === null || value.clientName === '') {
                    callback(new Error('请选择客户'));
                }else {
                    callback()
                }
            };
            return {
                rules: {
                    clientId: [
                        {validator: kehua, required: true, trigger: ['blur','change']},
                    ],
                    orderId: [
                        {validator: hueikuan, required: true, trigger: ['blur','change']},
                    ],
                    chukuId: [
                        {validator: chuku, required: true, trigger: ['blur','change']},
                    ],
                    returgoodTime: [
                        {required: true, message: '请选择退货时间', trigger: 'change' },
                    ]
                },
                pickerOptions: {//开票日期快捷选择方式
                    shortcuts: [{
                        text: '今天',
                        onClick(picker) {
                            picker.$emit('pick', new Date());
                        }
                    }, {
                        text: '昨天',
                        onClick(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24);
                            picker.$emit('pick', date);
                        }
                    }, {
                        text: '一周前',
                        onClick(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', date);
                        }
                    }]
                },
                thdlist:{
                returgoodId:0,
                    orderId:{
                        orderId:0,
                        orderTheme:'',
                    },
                    clientId:{
                        clientId:0,
                        updateTime:null,
                        clientIndustry:null,
                        clientSource:null,
                        clientUrl:null,
                        establishPerson:null,
                        establishTime:null,
                        clientName:'',
                        clientRank:null,
                        clientPhone:null,
                        clientMobile:null,
                        clientSite:null,
                        clientRemark:null,
                        clientPeople:null,
                        clientCjpeople:null,
                        clientState:0,
                        clientIffollowup:0,
                        clientSheng:null,
                        clientSz:null,
                        empId:null,
                        tfyclueFormsByClueId:null,
                        tfylinkmanFormsByClientId:null,
                        zbartersByClientId:null,
                        zcontractsByClientId:null,
                        zdeliverylogsByClientId:null,
                        zinvoicesByClientId:null,
                        zordersByClientId:null
                    },
                    chukuId:{
                        chukuId:0,
                        chukuNo:null
                    },
                    returgoodNo:'',
                    returgoodTime:'',
                    returgoodWctime:'',
                    returgoodYreimburse:0,
                    returgoodReimburse:0,
                    returgoodWarehouse:'',
                    returgoodState:'待入库',
                    returgoodRemark:'',
                    returgoodPass:'',
                    returgoodPeople:'',
                    returgoodZt:0,
                    returgoodTheme:'',
                    thxq:[]
                }, //订单主表信息
                xg:0,//是否是修改
                kehu:false,//客户弹出框
                kehuinput:'',//客户弹框搜索框
                kehulist:[],//客户表格信息
                pageSize:5,//客户分页页大小
                currPage:1,//客户当前页码，默认为1
                totalSize:0,//客户总记录数
                chuku:false,//客户弹出框
                chukuinput:'',//客户弹框搜索框
                chukulist:[],//客户表格信息
                pageSize4:5,//客户分页页大小
                currPage4:1,//客户当前页码，默认为1
                totalSize4:0,//客户总记录数
                dindan:false,//订单弹出框
                dindaninput:'',//订单弹框搜索框
                dindanlist:[],//订单表格信息
                pageSize2:5,//订单分页页大小
                currPage2:1,//订单当前页码，默认为1
                totalSize2:0,//订单总记录数
                thxq2:{
                    regodetailId:'',
                    prodetailId:{
                        prodetailId:0,
                        productId:null,
                        gdId:null,
                        prodetaiJpri:null,
                        productName:null,
                        prodetailSpri:null,
                        prodetailKcnum:null,
                        zbarterdetailsByProdetailId:null,
                        zcontractdetailsByProdetailId:null,
                        zdeliverydeliveriesByProdetailId:null,
                        zdeliverylogdeliveriesByProdetailId:null,
                        zorderdetailsByProdetailId:null,
                        qmodeldetails:null,
                        qpictures:null
                    },
                    regodetailNum:0,
                    regodetailBz:'',
                    regodetailJg:0,
                },
                chanp:false,
                chanpinput:'',
                pageSize3:5,//产品分页页大小
                currPage3:1,//产品当前页码，默认为1
                totalSize3:0,//产品总记录数
                proList:[],//产品集合
                dz:'',
                ys:1,
                ydx:10
            };
        },
        methods:{
            tzdz(){
                if(this.dz==='htxq'){
                    this.$router.push({
                        path:'/htxianqin',
                        query: {key:this.ddlist.conId}
                    });
                }else {
                    this.$router.push({
                        path:'/tuihuan',
                        query: {ys:this.ys,ydx:this.ydx}
                    });
                }
            },
            /*初始化商机编号*/
            initbusNo() {
                var date = new Date();
                var year = date.getFullYear();
                var month = date.getMonth() + 1;
                var day = date.getDate();
                if (month < 10) {
                    month = "0" + month;
                }
                if (day < 10) {
                    day = "0" + day;
                }
                //使用年月日作为中间数
                var busnosj = year + month + day;

                //使用时间戳作为最后五位随机数
                var a = date.getTime() + "";
                var b = a.substring(8, 13);

                //最后编号
                var busno = "TH_" + busnosj + "_" + b;
                this.thdlist.returgoodNo = busno;
            },
            //确定按钮
            addbusiness(formName) {
                    if(this.xg!=0){
                        this.xzfapiao();
                    }else{
                        this.$refs[formName].validate(valid => {
                            this.print(valid);
                            window.console.log(valid)
                            if (valid) {
                                if(this.thdlist.thxq.length>0){
                                    this.xzfapiao();
                                }else {
                                    this.$message({
                                        message: '请选择产品',
                                        type: 'warning'
                                    });
                                }
                            }else{
                                this.$message({
                                    message: '验证不通过！',
                                    type: 'warning'
                                });
                                return false;
                            }

                        });
                    }
            },
            /*客户当前页方法*/
            handleCurrentChange(val) {
                this.initData(val);
            },
            /*订单当前页方法*/
            handleCurrentChange2(val) {
                this.hetoninitData(val);
            },
            /*产品当前页方法*/
            handleCurrentChange3(val) {
                this.initData(val);
            },
            /*出库单当前页方法*/
            handleCurrentChange4(val) {
                this.ckinitData(val);
            },
            //客户弹框搜索方法
            cx(){
                this.initData(this.currPage);
            },
            //订单弹框搜索方法
            cx2(){
                this.ddinitData(this.currPage2);
            },
            //产品弹框搜索方法
            cx3(){
                this.initProData(this.currPage3);
            },
            //出库单弹框搜索方法
            cx4(){
                this.ckinitData(this.currPage4);
            },
            //根据退货单ID查询退货单详情所有产品信息
            thdxqinitData(dd){
                this.$axios.post("http://localhost:8088/thdan/thdcp",this.qs.stringify(
                    {search:dd}))
                    .then(v=>{
                        this.thdlist.thxq= v.data;
                    })
                    .catch()
            },
            discount(){
                this.thdlist.returgoodYreimburse=0;
                this.thdlist.thxq.forEach(a=>{
                    this.thdlist.returgoodYreimburse=this.thdlist.returgoodYreimburse+(a.regodetailJg*a.regodetailNum);
                    this.thdlist.returgoodReimburse=this.thdlist.returgoodYreimburse
                })
            },
            /*选择产品*/
            trueaddpro(){
                this.thdlist.returgoodYreimburse =0;
                this.thdlist.returgoodReimburse =0;
                this.thdlist.thxq=[];
                this.$refs.multipleSelection.selection.forEach((a,i)=>{
                    const htxq = {};
                    htxq.regodetailId=0;
                    htxq.prodetailId=0;
                    htxq.regodetailNum=null;
                    htxq.regodetailBz=null;
                    htxq.regodetailJg=null;
                    this.$set(htxq,'regodetailId',0);
                    this.$set(htxq,'prodetailId',a.prodetailId);
                    this.$set(htxq,'regodetailBz','');
                    this.$set(htxq,'regodetailNum',1);
                    this.$set(htxq,'regodetailJg',a.chukuJg);
                    this.$set(htxq,'sl',a.chukuKetueinumber);
                    this.thdlist.thxq.splice(i,0,htxq);
                    this.thdlist.returgoodYreimburse =this.thdlist.returgoodYreimburse +a.chukuJg;
                    this.thdlist.returgoodReimburse =this.thdlist.returgoodYreimburse;
                });
                this.multipleSelection=[];
                this.$refs.multipleSelection.clearSelection();
                this.chanp=false;
            },

            /*初始化产品*/
            initProData(dd){
                window.console.log();
                this.$axios.post("http://localhost:8088/chuku/list_chukuxq2",
                    this.qs.stringify({search:this.thdlist.chukuId.chukuId, page:dd, size:this.pageSize3,search2:this.chanpinput}))
                    .then(v=>{
                        this.proList = v.data.rows;
                        this.totalSize3=v.data.total;
                    })
                    .catch()
            },
            //点击订单输入框就查询订单信息
            dakai(){
                this.ddinitData(this.currPage2);
            },
            //点击出库输入框就查询订单信息
            dakai2(){
                this.ckinitData(this.currPage4);
            },
            //选择客户确定按钮
            xzkehu() {
                this.$refs.kehulist.selection.forEach((pro)=>{
                    this.thdlist.clientId=pro;
                });
                this.kehu=false;
                this.kehuinput='';
            },
            //选择出库确定按钮
            xzck() {
                this.$refs.chukulist.selection.forEach((pro)=>{
                    this.thdlist.chukuId=pro;
                });
                this.initProData(this.currPage3);
                this.chuku=false;
                this.chukuinput='';
            },
            //客户查询方法
            initData(dd){
                this.$axios.post("http://localhost:8088/dindan/kehu_list",this.qs.stringify(
                    {search:this.kehuinput, page:dd, size:this.pageSize,}))
                    .then(v=>{
                        this.kehulist = v.data.rows;
                        this.totalSize = v.data.total;
                    })
                    .catch()
            },
            //选择订单确定按钮
            xzdd() {
                this.$refs.dindanlist.selection.forEach((pro)=>{
                    this.thdlist.orderId=pro;
                });
                this.dindan=false;
                this.dindaninput='';
            },
            //订单查询方法
            ddinitData(dd){
                this.$axios.post("http://localhost:8088/dindan/list_dd",this.qs.stringify(
                    {search3:'退货单',search:this.dindaninput,search2:this.thdlist.clientId.clientId, page:dd, size:this.pageSize2,}))
                    .then(v=>{
                        this.dindanlist = v.data.rows;
                        this.totalSize2 = v.data.total;
                    })
                    .catch()
            },
            //订单查询方法
            ckinitData(dd){
                this.$axios.post("http://localhost:8088/chuku/list_chukutk2",this.qs.stringify(
                    {search:this.chukuinput,search2:this.thdlist.orderId.orderId, page:dd, size:this.pageSize4,}))
                    .then(v=>{
                        this.chukulist = v.data.rows;
                        this.totalSize4 = v.data.total;
                    })
                    .catch()
            },
            //新增修改退货单
            xzfapiao(){
                this.$axios.post("http://localhost:8088//thdan/add_thd",this.thdlist)
                    .then(()=>{
                        this.$message({
                            showClose: true,
                            type: 'success',
                            message: '新增成功!',
                        });
                        this.tzdz();
                    }).catch(()=>{
                        this.$message({
                            showClose: true,
                            message: '新增失败',
                            type: 'error'
                        });
                    }
                )
            },
        },
        created: function () {
            this.thdlist.returgoodPeople= JSON.parse(localStorage.getItem("user")).empName;
            this.initbusNo();
            this.initData(this.currPage);
            if(this.$route.query.key!=null){
                this.thdlist=this.$route.query.key;
                this.xg = 1;
                this.thdxqinitData(this.thdlist.returgoodId)
            }
            if(this.$route.query.dz!=null){
                this.dz=this.$route.query.dz;
            }
            if(this.$route.query.ys!=null){
                this.ys=this.$route.query.ys;
            }
            if(this.$route.query.ydx!=null){
                this.ydx=this.$route.query.ydx;
            }
    },
        filters: {
            formatDate: function (time) {
                if (time != null && time != "") {
                    var date = new Date(time);
                    return formatTimeToStr(date, "yyyy-MM-dd");
                } else {
                    return "";
                }
            },
            numFilter (value) {
                let realVal = ''
                if (!isNaN(value) && value!== '') {
                    // 截取当前数据到小数点后两位
                    realVal = parseFloat(value).toFixed(2)
                } else {
                    realVal = '--'
                }
                return realVal
            }
        }
    }
</script>

<style scoped>
    .shugan{
        border-left-color: rgb(70, 205, 207);
        border-left-width: 1.8px;
        height: 10px;
        border-left-style: solid;
        display: inline;
        font-size: 13px;
        margin-left: 25px;
    }

    /deep/ .el-scrollbar__wrap {
        overflow: scroll;
        width: 120%;
        height: 100%;
    }
</style>